#include "command.h"

// pathname是当前的路径
int myCd(char *pathname, train_t *train){
    // path is target_path
    // pathname is current_path
    DIR *dir = opendir(train->data);
    if(!dir){
        perror("myCd Opendir");
        return -1;
    }
    strcat(pathname, "/");
    strcat(pathname, train->data);

    return 0;
}

int myLs(train_t *t){

}

int myPuts(train_t *t){

}

int myGets(){

}

// 删除文件
int myRemove(const char* fileName){
    if(!fileName){
        fprintf(stderr,"fileName shouldn't be NULL");
        return -1;
    }
    int ret = remove(fileName);
    if(ret == -1){
        perror("Server Remove");
        return -1;
    }
    return 0;
}


int myPwd(train_t *train){

}

int myMkdir(){

}

// 删除目录
int myRmdir(const char* dirName){
    int ret = rmdir(dirName);
    if(ret == -1){
        perror("Server Rmdir");
        return 0;
    }
    return 1;

}

